package fy.uap.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.json.JSONObject;
//import org.apache.commons.logging.Log;
//import org.apache.commons.logging.LogFactory;
import org.springframework.web.servlet.ModelAndView;

import com.seeyon.ctp.common.AppContext;
import com.seeyon.ctp.common.authenticate.domain.User;
//import com.seeyon.v3x.common.authenticate.domain.User;
import com.seeyon.ctp.common.controller.BaseController;

import fy.form.listen.dao.MyOrgManager;
import fy.form.listen.set.OA_UAPAccountContrast;
import fy.uap.bean.SupplierBean;
import fy.uap.dao.CheckFinanceSupplierExistDao;
import fy.uap.dao.CheckProviderAndRangeDao;
import fy.uap.dao.ERPMergerOperateDao;
import fy.uap.dao.FinanceProviderMergerDao;
import fy.uap.dao.FundsOpeatorDao;
import fy.uap.dao.ProviderInfoOperateDao;
import fy.uap.dao.QueryProviderInfoAndRangeByCodeDao;
import fy.uap.dao.QuerySupplierInfoByCodeDao;
import fy.uap.manager.InitJSP;
import fy.util.MyUtil;

public class OA2UAPController extends BaseController {
	// private static Log log = LogFactory.getLog(OA2UAPController.class);

	private static final String fillProviderImportJSP = "fy_view/oa2uap/fillForm/fillProviderImport";

	private static final String invalidProviderJSP = "fy_view/oa2uap/fillForm/invalidProvider";

	private static final String mergerProviderJSP = "fy_view/oa2uap/fillForm/mergerProvider";

	private static final String mergerProviderInfoJSP = "fy_view/oa2uap/fillForm/mergerProviderInfoJSP";

	private static final String caigouhetonghuiqianJSP = "fy_view/oa2uap/fillForm/caigouhetonghuiqian";

	private static final String errorJSP = "fy_view/oa2other/error";

	private static final String jsonJSP = "fy_view/oa2uap/fillForm/JSON";

	// private static final String financeNewSupplier =
	// "fy_view/oa2uap/fillForm/finance_new_supplier";

	// private OrgManager orgManager;

	public ModelAndView getMergerProviderInfoJSP(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		ModelAndView modelAndView = null;
		if (AppContext.getCurrentUser() != null) {
			String code = MyOrgManager.getInstance()
					.getMemberByID(AppContext.getCurrentUser().getId()).getCode();
			if (code != null && !"".equals(code)) {
				modelAndView = new ModelAndView(mergerProviderInfoJSP);
				InitJSP.initMergerProviderInfoJSP(modelAndView);
			} else {
				modelAndView = new ModelAndView(errorJSP);
				modelAndView.addObject("errorMsg", "用户人员信息为设置工号，请先设置后，才能填写表单");
			}
		} else {
			modelAndView = new ModelAndView(errorJSP);
			modelAndView.addObject("errorMsg", "用户还未登陆。");
		}
		return modelAndView;
	}

	/**
	 * 用于供应商信息变更表，查询供应商信息
	 * 
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	public ModelAndView findProviderInfoMPI(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		ModelAndView modelAndView = new ModelAndView(jsonJSP);
		response.setCharacterEncoding("utf-8");
		if (AppContext.getCurrentUser() != null) {
			String code = request.getParameter("providerCode").replace(" ", "");
			String corp = OA_UAPAccountContrast.getUapAccountID(request
					.getParameter("corp"));

			if (MyUtil.strIsNotNull(code) && MyUtil.strIsNotNull(corp)) {
				modelAndView
						.addObject("jsonStr", ProviderInfoOperateDao
								.queryProviderInfoMPI(code, corp));
			} else {
				modelAndView.addObject("jsonStr",
						"{success:false, msg:'供应商编码或者用户所在制造部信息为空。'}");
			}
		} else {
			modelAndView.addObject("jsonStr", "{success:false, msg:'用户还未登陆。'}");
		}
		return modelAndView;
	}

	public ModelAndView getFillProviderImportJSP(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		ModelAndView modelAndView = null;
		// String userCode = getCurrentUserCode();
		// if (userCode != null) {
		if (AppContext.getCurrentUser() != null) {
			String code = MyOrgManager.getInstance()
					.getMemberByID(AppContext.getCurrentUser().getId()).getCode();
			if (code != null && !"".equals(code)) {
				modelAndView = new ModelAndView(fillProviderImportJSP);
				InitJSP.initFillProviderImportJSP(modelAndView,code);
				modelAndView.addObject("operator", "0");
			} else {
				modelAndView = new ModelAndView(errorJSP);
				modelAndView.addObject("errorMsg", "用户人员信息为设置工号，请先设置后，才能填写表单");
			}
		} else {
			modelAndView = new ModelAndView(errorJSP);
			modelAndView.addObject("errorMsg", "用户还未登陆。");
		}
		return modelAndView;
	}

	public ModelAndView getFillProviderImportByCodeJSP(
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		ModelAndView modelAndView = null;
		if (AppContext.getCurrentUser() != null) {
			String code = MyOrgManager.getInstance()
					.getMemberByID(AppContext.getCurrentUser().getId()).getCode();
			if (code != null && !"".equals(code)) {
				modelAndView = new ModelAndView(fillProviderImportJSP);
				InitJSP.initFillProviderImportJSP(modelAndView,code);
				modelAndView.addObject("operator", "1");
			} else {
				modelAndView = new ModelAndView(errorJSP);
				modelAndView.addObject("errorMsg", "用户人员信息为设置工号，请先设置后，才能填写表单");
			}
		} else {
			modelAndView = new ModelAndView(errorJSP);
			modelAndView.addObject("errorMsg", "用户还未登陆。");
		}
		return modelAndView;
	}

	/**
	 * 用于供应商导入，查询供应商信息
	 * 
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	public ModelAndView findProviderInfo(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		ModelAndView mav = new ModelAndView(jsonJSP);
		response.setCharacterEncoding("utf-8");

		if (AppContext.getCurrentUser() != null) {
			String providerCode = request.getParameter("providerCode");
			if (providerCode != null && !"".equals(providerCode)) {

				SupplierBean bean = QuerySupplierInfoByCodeDao
						.querySupplierInfo(providerCode, AppContext.getCurrentUser()
								.getLoginAccount());
				if (bean != null) {
					mav.addObject("jsonStr", bean.toJSON());
				} else
					mav.addObject("jsonStr", 3);
			} else {
				mav.addObject("jsonStr", 2);
			}
		} else {
			mav.addObject("jsonStr", 1);
		}
		return mav;
	}

	public ModelAndView checkProviderNameIsExist(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		ModelAndView mav = new ModelAndView(jsonJSP);
		response.setCharacterEncoding("utf-8");

		String providerName = request.getParameter("providerName");
		if (providerName != null && !"".equals(providerName)) {
			providerName = java.net.URLDecoder.decode(providerName, "utf-8");
			String isExist = request.getParameter("isExist");
			String writer = request.getParameter("writer");

			if ("true".equals(isExist) && "1".equals(writer)) {
				String typeNodes = MyUtil.clearEmpty(request
						.getParameter("typeNodes"));
				String companyNodes = MyUtil.clearEmpty(request
						.getParameter("companyNodes"));
				String code = MyUtil.clearEmpty(request.getParameter("code"));

				if (MyUtil.strIsNotNull(typeNodes)
						&& MyUtil.strIsNotNull(companyNodes)
						&& MyUtil.strIsNotNull(code)) {
					CheckProviderAndRangeDao dao = new CheckProviderAndRangeDao();
					if (dao.checkProviderNameAndRange(providerName, typeNodes,
							companyNodes, code)) {
						JSONObject jo = new JSONObject();
						jo.put("code", dao.getCode());
						jo.put("msg", dao.getMsg());
						jo.put("success", true);
						mav.addObject("jsonStr", jo.toString());
						jo = null;
					} else {
						mav.addObject("jsonStr", "{success : 'false'}");
					}
					dao = null;
				} else {
					JSONObject jo = new JSONObject();
					jo.put("success", false);
					jo.put("error", "获得的参数不能为空");
					mav.addObject("jsonStr", jo.toString());
					jo = null;
				}
			} else {
				CheckProviderAndRangeDao dao = new CheckProviderAndRangeDao();
				if (dao.checkProviderNameIsExist(providerName)) {
					JSONObject jo = new JSONObject();
					jo.put("code", dao.getCode());
					jo.put("success", true);
					mav.addObject("jsonStr", jo.toString());
					jo = null;
				} else {
					mav.addObject("jsonStr", "{success:false}");
				}
				dao = null;
			}
		} else {
			mav.addObject("jsonStr", "error");
		}

		return mav;
	}

	/**
	 * 用于供应商导入查询供应编码是否存在
	 * 
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	public ModelAndView checkProviderCodeIsExist(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		ModelAndView mav = new ModelAndView(jsonJSP);
		response.setCharacterEncoding("utf-8");

		if (AppContext.getCurrentUser() != null) {
			String providerCode = request.getParameter("providerCode");
			if (providerCode != null && !"".equals(providerCode)) {
				mav.addObject("jsonStr", QuerySupplierInfoByCodeDao
						.checkProviderCodeIsExist(providerCode));
			} else {
				mav.addObject("jsonStr", 4);
			}
		} else {
			mav.addObject("jsonStr", 3);
		}
		return mav;
	}

	public ModelAndView getInvalidProviderJSP(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		ModelAndView modelAndView = null;

		if (AppContext.getCurrentUser() != null) {
			String code = MyOrgManager.getInstance()
					.getMemberByID(AppContext.getCurrentUser().getId()).getCode();
			if (code != null && !"".equals(code)) {
				modelAndView = new ModelAndView(invalidProviderJSP);
				InitJSP.initInvalidProviderJSP(modelAndView,code);
			} else {
				modelAndView = new ModelAndView(errorJSP);
				modelAndView.addObject("errorMsg", "用户人员信息为设置工号，请先设置后，才能填写表单");
			}
		} else {
			modelAndView = new ModelAndView(errorJSP);
			modelAndView.addObject("errorMsg", "用户还未登陆。");
		}
		return modelAndView;
	}

	/**
	 * 查询供应商信息和供货范围，用于供应商导出
	 * 
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	public ModelAndView findProviderInfoAndRangeByCode(
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		ModelAndView modelAndView = new ModelAndView(jsonJSP);
		response.setCharacterEncoding("utf-8");

		if (AppContext.getCurrentUser() != null) {
			String code = request.getParameter("code");
			String accountID = request.getParameter("accountID");

			if (code != null && !"".equals(code) && accountID != null
					&& !"".equals(accountID)) {
				String uapAccoutID = OA_UAPAccountContrast
						.getUapAccountID(accountID);
				if (uapAccoutID != null) {
					modelAndView.addObject("jsonStr",
							QueryProviderInfoAndRangeByCodeDao
									.queryProviderInfoAndRange(code,
											uapAccoutID));
				} else {
					modelAndView.addObject("jsonStr", 1);
				}
			} else {
				modelAndView.addObject("jsonStr", 3);
			}

		} else {
			modelAndView.addObject("jsonStr", 2);
		}
		return modelAndView;
	}

	/**
	 * 采购合同会签单查询供货范围
	 * 
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	public ModelAndView getProviderInfoAndRangeXMLByCode(
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		ModelAndView modelAndView = new ModelAndView(jsonJSP);
		response.setCharacterEncoding("utf-8");

		if (AppContext.getCurrentUser() != null) {
//			User user = AppContext.getCurrentUser();
			String code = request.getParameter("code");
			String accountID = String.valueOf(AppContext.getCurrentUser().getLoginAccount());

			
			
			if (code != null && !"".equals(code) && accountID != null
					&& !"".equals(accountID)) {
				String uapAccoutID = OA_UAPAccountContrast
						.getUapAccountID(accountID);
				if (uapAccoutID != null) {
					modelAndView.addObject("jsonStr",
							QueryProviderInfoAndRangeByCodeDao
									.getProviderInfoAndRangeXMLByCode(code,
											uapAccoutID));
				} else {
					modelAndView.addObject("jsonStr", 1);
				}
			} else {
				modelAndView.addObject("jsonStr", 3);
			}

		} else {
			modelAndView.addObject("jsonStr", 2);
		}
		return modelAndView;
	}

	/**
	 * 年度协议，查询供应商供货范围
	 * 
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	public ModelAndView getProviderInfoAndRangeXMLByCodeAndCorp(
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		ModelAndView modelAndView = new ModelAndView(jsonJSP);
		response.setCharacterEncoding("utf-8");

		if (AppContext.getCurrentUser() != null) {
			String code = request.getParameter("code");
			String accountID = request.getParameter("corp").replace("key_", "");

			if (code != null && !"".equals(code) && accountID != null
					&& !"".equals(accountID)) {
				modelAndView.addObject("jsonStr",
						QueryProviderInfoAndRangeByCodeDao
								.getProviderInfoAndRangeXMLByCode(code,
										accountID));
			} else {
				modelAndView.addObject("jsonStr", 3);
			}

		} else {
			modelAndView.addObject("jsonStr", 2);
		}
		return modelAndView;
	}

	public ModelAndView getMergerProviderJSP(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		ModelAndView modelAndView = null;

		// String userCode = getCurrentUserCode();
		// if (userCode != null) {
		if (AppContext.getCurrentUser() != null) {

			modelAndView = new ModelAndView(mergerProviderJSP);
			InitJSP.initMergerProviderJSP(modelAndView);

		}
		return modelAndView;
	}

	/**
	 * 用户供应商更名合并，查询目标供应商和原供应商信息
	 * 
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	public ModelAndView findProviderInfoByCode(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		ModelAndView modelAndView = null;
		modelAndView = new ModelAndView(jsonJSP);
		response.setCharacterEncoding("utf-8");
		if (AppContext.getCurrentUser() != null) {

			String type = request.getParameter("type");
			String code = request.getParameter("code");

			if (type != null && code != null && !"".equals(type)
					&& !"".equals(code)) {
				SupplierBean bean = QuerySupplierInfoByCodeDao
						.querySupplierInfo(code, type);
				if (bean != null) {
					modelAndView.addObject("jsonStr", bean.toJSON());
				} else
					modelAndView.addObject("jsonStr", 1);
			} else {
				modelAndView.addObject("jsonStr", 3);
			}

		} else {
			modelAndView.addObject("jsonStr", 2);
		}
		return modelAndView;
	}

	/**
	 * 获取采购合同会签单填写界面
	 * 
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	public ModelAndView getCaigouhetonghuiqianJSP(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		ModelAndView modelAndView = null;
		if (AppContext.getCurrentUser() != null) {
			// long loginAccount = AppContext.getCurrentUser().getLoginAccount();
			modelAndView = new ModelAndView(caigouhetonghuiqianJSP);
			// InitJSP.initCaigouhetonghuiqianJSP(modelAndView);
		} else {
			modelAndView = new ModelAndView(errorJSP);
			modelAndView.addObject("errorMsg", "用户还未登陆。");
		}
		return modelAndView;
	}

	/**
	 * 通过供应商编码获取供应商信息
	 * 
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	public ModelAndView queryProviderInfoAndRangeByCode(
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		ModelAndView modelAndView = new ModelAndView(jsonJSP);
		response.setCharacterEncoding("utf-8");

		if (AppContext.getCurrentUser() != null) {
			String code = request.getParameter("code");
			String accountID = String.valueOf(AppContext.getCurrentUser()
					.getLoginAccount());

			if (code != null && !"".equals(code)) {
				String uapAccoutID = OA_UAPAccountContrast
						.getUapAccountID(accountID);
				if (uapAccoutID != null) {
					modelAndView.addObject("jsonStr",
							QueryProviderInfoAndRangeByCodeDao
									.queryProviderInfoAndRange(code,
											uapAccoutID));
				} else {
					modelAndView.addObject("jsonStr", 1);
				}
			} else {
				modelAndView.addObject("jsonStr", 3);
			}

		} else {
			modelAndView.addObject("jsonStr", 2);
		}
		return modelAndView;
	}

	public ModelAndView supplierExist(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		ModelAndView modelAndView = new ModelAndView(jsonJSP);
		response.setCharacterEncoding("utf-8");

		if (AppContext.getCurrentUser() != null) {
			String code = MyOrgManager.getInstance()
					.getMemberByID(AppContext.getCurrentUser().getId()).getCode();
			if (code != null && !"".equals(code)) {
				String[] checkArray = request.getParameterValues("checkArray");
				String operate = request.getParameter("operate");
				String corpID = request.getParameter("corpID");
				corpID = corpID != null ? corpID.replace("key_", "") : "";
				if (((("1".equals(operate) || "2".equals(operate))
						&& corpID != null && !"".equals(corpID)) || "3"
						.equals(operate))
						&& checkArray != null
						&& checkArray.length != 0) {

					CheckFinanceSupplierExistDao dao = new CheckFinanceSupplierExistDao();
					dao.setCheckArray(checkArray);
					dao.setCorpID(corpID);

					if ("1".equals(operate)) {
						dao.checkName();}
					else if ("2".equals(operate)) {
						dao.checkCode();}
					else {
						dao.queryCode();}

					modelAndView.addObject("jsonStr", dao.getMsg());

				} else {
					modelAndView.addObject("jsonStr", 3);
				}
			} else {
				modelAndView.addObject("jsonStr", "OA用户信息的人员编码不能为空");
			}
		} else {
			modelAndView.addObject("jsonStr", 2);
		}
		return modelAndView;
	}

	/**
	 * 查询财务类供应商名称
	 * 
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	public ModelAndView financeProviderOperate(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		ModelAndView modelAndView = new ModelAndView(jsonJSP);
		response.setCharacterEncoding("utf-8");
		if (AppContext.getCurrentUser() != null) {
			String operate = request.getParameter("operate");
			if (MyUtil.strIsNotNull(operate)) {
				if (operate.equals("1")) {
					String supplierCode = request.getParameter("code");
					String pk_corp = request.getParameter("pk_corp");
					String isNew = request.getParameter("isNew");
					if (MyUtil.strIsNotNull(supplierCode)) {
						if (MyUtil.strIsNotNull(pk_corp)) {
							modelAndView.addObject("jsonStr",
									FinanceProviderMergerDao
											.queryFinanceProviderNameByCode(
													supplierCode, pk_corp,
													isNew));
						} else {
							modelAndView.addObject("jsonStr", 3);
						}
					} else {
						modelAndView.addObject("jsonStr", 1);
					}
				} else if (operate.equals("2")) {
					String supplierName = request.getParameter("name");
					if (MyUtil.strIsNotNull(supplierName)) {
						supplierName = java.net.URLDecoder.decode(supplierName,
								"utf-8");
						String[] supplierNameArray = supplierName
								.split("【连接符】");
						if (supplierNameArray.length > 0) {
							modelAndView
									.addObject(
											"jsonStr",
											FinanceProviderMergerDao
													.checkProviderNameExist(supplierNameArray));
						} else {
							modelAndView.addObject("jsonStr", 5);
						}
					} else {
						modelAndView.addObject("jsonStr", 5);
					}
				} else if (operate.equals("3")) {
					String supplierCode = request.getParameter("name");
					if (MyUtil.strIsNotNull(supplierCode)) {
						String[] supplierCodeArray = supplierCode.split(",");
						if (supplierCodeArray.length > 0) {
							modelAndView
									.addObject(
											"jsonStr",
											FinanceProviderMergerDao
													.checkProviderCodeExist(supplierCodeArray));
						} else {
							modelAndView.addObject("jsonStr", 5);
						}
					} else {
						modelAndView.addObject("jsonStr", 5);
					}
				}
			} else {
				modelAndView.addObject("jsonStr", 4);
			}

		} else {
			modelAndView.addObject("jsonStr", 2);
		}
		return modelAndView;
	}

	/**
	 * ERP供应商合并 操作
	 * 
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	public ModelAndView erpMergerOperate(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		ModelAndView modelAndView = new ModelAndView(jsonJSP);
		response.setCharacterEncoding("utf-8");
		if (AppContext.getCurrentUser() != null) {
			String operate = request.getParameter("operate").replace(" ", "");
			if (MyUtil.strIsNotNull(operate)) {
				if (operate.equals("3")) {

					String number = request.getParameter("number").replace(" ",
							"");
					if (MyUtil.strIsNotNull(number)) {
						modelAndView.addObject("jsonStr",
								ERPMergerOperateDao.queryFormInfo(number));
					} else {
						modelAndView.addObject("jsonStr",
								"{success : false, data : 'OA单据编号不能为空'}");
					}
				} else if (operate.equals("4")) {
					String corp = request.getParameter("corp");
					String[] siteArray = request.getParameterValues("site");
					String[] codeArray = request.getParameterValues("code");

					if (MyUtil.strIsNotNull(corp) && siteArray != null
							&& siteArray.length > 0 && codeArray != null
							&& codeArray.length == siteArray.length) {
						corp = corp.replace("key_", "");

						modelAndView.addObject("jsonStr", ERPMergerOperateDao
								.yiHeBing(corp, codeArray, siteArray));
					} else {
						modelAndView
								.addObject("jsonStr",
										"{success : false, msg : '供应制造部/供应商编码/供应商地点不能为空'}");
					}

				} else {
					String supplierCode = request.getParameter("code").replace(
							" ", "");
					String ou_id = request.getParameter("ou_id")
							.replace("key_", "").replace(" ", "");
					if (MyUtil.strIsNotNull(supplierCode)
							&& MyUtil.strIsNotNull(ou_id)) {
						if (operate.equals("1")) {
							modelAndView.addObject("jsonStr",
									ERPMergerOperateDao
											.queryProviderNameFromERP(
													supplierCode, ou_id, null));
						} else if (operate.equals("2")) {
							modelAndView.addObject("jsonStr",
									ERPMergerOperateDao
											.queryProviderNameFromUAP(
													supplierCode, ou_id));
						}
					} else {
						modelAndView.addObject("jsonStr",
								"{success : false, data : '供应商编码或供应制造部不能为空'}");
					}
				}

			} else {
				modelAndView.addObject("jsonStr",
						"{success : false, data : '访问操作缺少参数，请联系OA系统管理员'}");
			}

		} else {
			modelAndView.addObject("jsonStr",
					"{success : false, data : '无当前用户登陆信息，请重新登陆。'}");
		}
		return modelAndView;
	}

	/**
	 * UAP 资金系统， OA系统读取资金系统有效付款计划
	 * 
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	public ModelAndView fundCorpPlan(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		ModelAndView modelAndView = new ModelAndView(jsonJSP);
		response.setCharacterEncoding("utf-8");
		if (AppContext.getCurrentUser() != null) {
			String operate = request.getParameter("operate");
			if ("1".equals(operate)) {
				modelAndView.addObject("jsonStr", FundsOpeatorDao
						.queryOption(request.getParameter("baoxiao")));
			} else if ("2".equals(operate)) {
				String no = request.getParameter("no");
				String begain = request.getParameter("begain");
				String end = request.getParameter("end");
				if (!MyUtil.strIsNotNull(no) && !MyUtil.strIsNotNull(begain)
						&& !MyUtil.strIsNotNull(end)) {
					modelAndView.addObject("jsonStr",
							"{success : false, data : '查询条件不能全部为空。'}");
				} else {
					String member = MyOrgManager.getInstance()
							.getMemberByID(AppContext.getCurrentUser().getId())
							.getCode();
					if (MyUtil.strIsNotNull(member)) {
						modelAndView.addObject("jsonStr", FundsOpeatorDao
								.queryFundCorpPlan(member, no, begain, end));
					} else {
						modelAndView
								.addObject("jsonStr",
										"{success : false, data : '用户工号不能为空，请联系OA管理员添加人员工号。'}");
					}
				}

			} else {
				modelAndView.addObject("jsonStr",
						"{success : false, data : '参数不能为空，请重试！'}");
			}
		} else {
			modelAndView.addObject("jsonStr",
					"{success : false, data : '无当前用户登陆信息，请重新登陆。'}");
		}
		return modelAndView;
	}
}
